#include "GameObject.h"
#include "IComponent.h"
#include "Physics.h"
#include "Body.h"


GameObject::GameObject(void)
{
}


GameObject::~GameObject(void)
{
}

void GameObject::addComponent(IComponent* com)
{
	lComponents.push_back(com);
}

void GameObject::removeComponent(IComponent* com)
{
	lComponents.remove(com);
}

void GameObject::update()
{
	for(IComponent* com : lComponents)		
		com->update();
}

IComponent* GameObject::getComponentById(COMPONENT id)
{
	for(IComponent* com : lComponents)
	{
		if(com->_cId == id) return com;
	}	
	return NULL;
}

void GameObject::render()
{	
	Body* bd = (Body*)getComponentById(BODY1);
	Physics* phy = (Physics*)getComponentById(PHYSICS);
	bd->render(phy->getPosition());
}
